import java.security.MessageDigest;
import java.security.*;
import java.util.Random;

public class Auth {
	private static byte[] hash(byte[] s) throws NoSuchAlgorithmException{
		MessageDigest md;
		md = MessageDigest.getInstance("MD5");
		md.update(s);
		return md.digest();
	 }
	 
	 public static byte[] compute(String seed, String password, int sequence) throws NoSuchAlgorithmException{
		 byte[] m = (seed+password).getBytes();
		 for (int i = 0; i < sequence; i++) {
			 m = hash(m);
		 }
		 return m;
	 }
	 
	 public static String makeSeed(){
		 SecureRandom r = new SecureRandom();
		 return r.generateSeed(16).toString();
	 }
	 
	 public static int makeSequence(){
		 Random r = new Random();
		 return (r.nextInt(500)+200);
	 }
}
